package com.payment.controller;

import com.common.domain.pojo.Result;
import com.payment.domain.dto.OrderPaymentDtoRefundDto;
import com.payment.domain.pojo.RefundRecord;
import com.payment.service.IRefundRecordService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/payment/refund")
public class RefundRecordController {

    @Resource
    IRefundRecordService iRefundRecordService;

    // 退款
    @PostMapping
    public Result<Boolean> refund(@RequestBody OrderPaymentDtoRefundDto order) {
        Boolean res = iRefundRecordService.refund(order);
        return Result.success(res);
    }

    // 查询退款结果
    @GetMapping("/query/status")
    public Result<Byte> queryRefundResult(@RequestParam("orderNo") String orderNo) {
        return Result.success(iRefundRecordService.queryRefundResult(orderNo));
    }

    // 查询订单退款记录
    @GetMapping("/query")
    public Result<List<RefundRecord>> queryRefundRecord(@RequestParam("orderNo") String orderNo) {
        return Result.success(iRefundRecordService.queryRefundRecord(orderNo));
    }

}
